/*
 * scenemngr.h
 *
 *  Created on: 10-ott-2008
 *      Author: fpistonesi
 */
/*

 Copyright (c) 2008-2009 Fabrizio Pistonesi

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 */

#ifndef SCENEMNGR_H_
#define SCENEMNGR_H_

#include "camera.h"
#include "console.h"
#include "cursor.h"
#include "hotspotmap.h"
#include "node.h"
#include "panel.h"
#include "patch.h"
#include "cubic.h"
#include "spherical.h"
#include "slide.h"
#include "sound.h"
#include "subtitle.h"
#include "transition.h"
#include "sensor.h"

#include <irrlicht.h>
#include <string>
#include <vector>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#include <audiere.h>
using namespace audiere;

class SceneMngr
{
public:
  SceneMngr(IrrlichtDevice* device);
  virtual ~SceneMngr();

  IrrlichtDevice* Device;
  std::vector<std::string> NodeList;
  s32 NodeCount;
  Node* ThisNode;
  //Node **OverlayStack;
  std::vector<Node *> OverlayStack;

  stringw Project;
  stringw Title;
  s32 StartNode;

  SubTitle* Subtitle;
  Camera* CameraCtrl;
  Cursor* CursorCtrl;
  Transition* TransitionCtrl;

  Sensor* SelectedSensor;

  AudioDevicePtr AudioDev;
  Sound *BgMusic;

  bool loadProject(stringc project);
  bool saveNode(const c8* filename);
  Node* loadNode(std::string, s32 id);    //a.viarengo  replace const c8* filename with std::string
  void loadPatches(io::IXMLReader* reader, Node* node);
  void loadSounds(io::IXMLReader* reader, Node* node);
  void loadSensors(io::IXMLReader* reader, Node* node);

  bool gotoNode(s32 id, ETRANSITION_TYPE effect=ETT_FADE,int time = 500, float factor = 2);
  bool overlayNode(s32 id);
  void closeOverlay();
  SubTitle* getSubtitle();
  Camera*   getCamera();
  Cursor*   getCursor();
  Transition* getTransition();

  void update(const SEvent& event);
  void updateListenerPosition(const SEvent& event);
  void updateSensors(const SEvent& event);
};

#endif /* SCENEMNGR_H_ */
